package com.epin.business.commons.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import com.epin.base.plugins.BaseController;
import com.epin.business.system.entity.Role;
import com.epin.util.SessionUtil;

@Controller
@RequestMapping("/test")
public class TestController extends BaseController{
	
	
	@RequestMapping("/{c1}/{c2}/to")
	public String index(@PathVariable String c1, @PathVariable String c2) {
		
		// 判断是否为超级管理员
		Role role = SessionUtil.getCurrentUser().getRole();
		if (!ADMIN_ROLE_KEY.equals(role.getKey())) {
			return "403";
		}
		
		return c1 + "/" + c2;
	}
	
	
	@RequestMapping("/{c1}/{c2}/{c3}/to")
	public String index(@PathVariable String c1, @PathVariable String c2, @PathVariable String c3) {
		
		// 判断是否为超级管理员
		Role role = SessionUtil.getCurrentUser().getRole();
		if (!ADMIN_ROLE_KEY.equals(role.getKey())) {
			return "403";
		}
		
		return c1 + "/" + c2 + "/" + c3;
	}


	@RequestMapping("/{c1}/{c2}/{c3}/{c4}/to")
	public String index(@PathVariable String c1, @PathVariable String c2, @PathVariable String c3, @PathVariable String c4) {
		
		// 判断是否为超级管理员
		Role role = SessionUtil.getCurrentUser().getRole();
		if (!ADMIN_ROLE_KEY.equals(role.getKey())) {
			return "403";
		}
		
		return c1 + "/" + c2 + "/" + c3 + "/" + c4;
	}
	
	
	@RequestMapping("/{c1}/{c2}/{c3}/{c4}/{c5}/to")
	public String index(@PathVariable String c1, @PathVariable String c2, @PathVariable String c3, @PathVariable String c4, @PathVariable String c5) {
		
		// 判断是否为超级管理员
		Role role = SessionUtil.getCurrentUser().getRole();
		if (!ADMIN_ROLE_KEY.equals(role.getKey())) {
			return "403";
		}
		
		return c1 + "/" + c2 + "/" + c3 + "/" + c4 + "/" + c5;
	}
}
